<?php
namespace app\modules\pay\provider;

use app\modules\pay\utils\SignUtil;

class AlipayProvider {

    //支付
    public function getPayCode($order_no,$total_amount,$body,$openid,$config)
    {
        $params = [
            'mch_no'=>$config['mch_no'],
            'sign_type'=>'MD5',
            'nonce_str'=>\Yii::$app->getSecurity()->generateRandomString(),
            'out_trade_no'=>$order_no,
            'total_amount'=>$total_amount,
            'body'=>$body,
            'ip'=>\Yii::$app->getRequest()->getUserIP(),
            'mach_no'=>$config['mach_no'],
            'notify_url'=>\Yii::$app->params['payment']['domain'] . "/pay/notify/pay-notify",
        ];
        $params['sign'] = SignUtil::sign($params,$config['sign_key']);
        $params['service'] = "pay.mobile.nativepay";
        $params['pay_channel'] = "2";
        return $params;
    }
}